package com.lanhai.crowd.service.impl;

import com.lanhai.crowd.entity.Menu;
import com.lanhai.crowd.entity.MenuExample;
import com.lanhai.crowd.mapper.MenuMapper;
import com.lanhai.crowd.service.api.MenuService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MenuServiceImpl implements MenuService {

    @Autowired
    private MenuMapper menuMapper;

    private Logger log = LoggerFactory.getLogger(MenuServiceImpl.class);


    @Override
    public List<Menu> getAll() {
        List<Menu> menuList = menuMapper.selectByExample(new MenuExample());
        return menuList;
    }

    @Override
    public void saveMenu(Menu menu) {

        menuMapper.insert(menu);
    }

    @Override
    public void updateMenu(Menu menu) {

        // 有选择的更新
        menuMapper.updateByPrimaryKeySelective(menu);
    }

    @Override
    public void deleteMenu(Integer id) {

        // 根据primaryKey删除Menu
        menuMapper.deleteByPrimaryKey(id);
    }
}
